package com.nPones;

import android.content.Context;
import android.graphics.Canvas;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.SurfaceHolder;
import android.view.SurfaceHolder.Callback;
import android.view.SurfaceView;
import baseClass.Global;
import baseClass.Layer;
import baseClass.Logo;
import baseClass.Scene;
import baseClass.Sprite_Default;
import java.util.ArrayList;
import mainSrc.MainDirector;

public class GameView
  extends SurfaceView
  implements SurfaceHolder.Callback
{
  Context m_context;
  MainDirector m_director;
  Logo m_logo;
  GameThread m_thread;
  
  public GameView(Context paramContext, AttributeSet paramAttributeSet, MainActivity paramMainActivity)
  {
    super(paramContext, paramAttributeSet);
    paramAttributeSet = getHolder();
    paramAttributeSet.addCallback(this);
    Global.GetInstance().ObjectInit(paramContext, paramMainActivity);
    this.m_thread = new GameThread(paramContext, paramAttributeSet);
    this.m_logo = new Logo(paramContext, 2130837569, 2130837510);
    this.m_context = paramContext;
  }
  
  public void LoadGame(Canvas paramCanvas)
  {
    this.m_director = new MainDirector();
    this.m_logo.isLoadFile = true;
    this.m_logo.DrawLogo(paramCanvas);
  }
  
  public void onTouch(int paramInt, float paramFloat1, float paramFloat2)
  {
    Scene localScene = this.m_director.Current_scene;
    int i = 0;
    int j;
    for (;;)
    {
      if (i >= localScene.getSubnum()) {
        return;
      }
      j = 0;
      if (j < ((Layer)localScene.SubLayer.get(i)).getSubnum()) {
        break;
      }
      i += 1;
    }
    if ((((Layer)localScene.SubLayer.get(i)).touch) && (((Sprite_Default)((Layer)localScene.SubLayer.get(i)).SubSprite.get(j)).state == 2) && (((Layer)localScene.SubLayer.get(i)).visible) && (((Sprite_Default)((Layer)localScene.SubLayer.get(i)).SubSprite.get(j)).visible) && (((Sprite_Default)((Layer)localScene.SubLayer.get(i)).SubSprite.get(j)).Touch_Check(paramFloat1, paramFloat2))) {
      switch (paramInt)
      {
      }
    }
    for (;;)
    {
      j += 1;
      break;
      ((Sprite_Default)((Layer)localScene.SubLayer.get(i)).SubSprite.get(j)).onTouch_Down(paramFloat1, paramFloat2, this.m_director);
      continue;
      ((Sprite_Default)((Layer)localScene.SubLayer.get(i)).SubSprite.get(j)).onTouch_Move(paramFloat1, paramFloat2, this.m_director);
      continue;
      ((Sprite_Default)((Layer)localScene.SubLayer.get(i)).SubSprite.get(j)).onTouch_Up(paramFloat1, paramFloat2, this.m_director);
    }
  }
  
  public boolean onTouchEvent(MotionEvent paramMotionEvent)
  {
    if (this.m_logo.isCompleteLoad) {
      switch (paramMotionEvent.getAction())
      {
      }
    }
    do
    {
      do
      {
        do
        {
          return true;
        } while (this.m_director.Current_scene.getSubnum() == 0);
        onTouch(0, paramMotionEvent.getX(), paramMotionEvent.getY());
        return true;
      } while (this.m_director.Current_scene.getSubnum() == 0);
      onTouch(1, paramMotionEvent.getX(), paramMotionEvent.getY());
      return true;
    } while (this.m_director.Current_scene.getSubnum() == 0);
    onTouch(2, paramMotionEvent.getX(), paramMotionEvent.getY());
    return true;
  }
  
  public void runView(Canvas paramCanvas)
  {
    if (!this.m_logo.isDrawLogo)
    {
      this.m_logo.DrawLogo(paramCanvas);
      return;
    }
    if (!this.m_logo.isLoadFile)
    {
      LoadGame(paramCanvas);
      return;
    }
    if (!this.m_logo.isCompleteLoad)
    {
      this.m_logo.fadeout_logo(paramCanvas);
      return;
    }
    this.m_director.ShowScene(paramCanvas);
  }
  
  public void surfaceChanged(SurfaceHolder paramSurfaceHolder, int paramInt1, int paramInt2, int paramInt3) {}
  
  public void surfaceCreated(SurfaceHolder paramSurfaceHolder)
  {
    if (this.m_thread.getState() == Thread.State.TERMINATED) {
      this.m_thread = new GameThread(this.m_context, paramSurfaceHolder);
    }
    this.m_thread.SetLoop(true);
    this.m_thread.start();
  }
  
  public void surfaceDestroyed(SurfaceHolder paramSurfaceHolder)
  {
    int i = 1;
    this.m_thread.SetLoop(false);
    for (;;)
    {
      if (i == 0) {
        return;
      }
      try
      {
        this.m_thread.join();
        i = 0;
      }
      catch (InterruptedException paramSurfaceHolder) {}
    }
  }
  
  class GameThread
    extends Thread
  {
    private boolean Is_Run;
    SurfaceHolder m_holder;
    
    public GameThread(Context paramContext, SurfaceHolder paramSurfaceHolder)
    {
      this.m_holder = paramSurfaceHolder;
      this.Is_Run = true;
    }
    
    public void SetLoop(boolean paramBoolean)
    {
      this.Is_Run = paramBoolean;
    }
    
    public void run()
    {
      for (;;)
      {
        if (!this.Is_Run) {
          return;
        }
        Object localObject7 = null;
        Object localObject8 = null;
        Object localObject9 = null;
        Object localObject5 = null;
        Object localObject2 = localObject7;
        Object localObject4 = localObject8;
        Object localObject1 = localObject9;
        try
        {
          SurfaceHolder localSurfaceHolder = this.m_holder;
          localObject2 = localObject7;
          localObject4 = localObject8;
          localObject1 = localObject9;
          localObject1 = localObject5;
          try
          {
            localObject2 = this.m_holder.lockCanvas();
            localObject1 = localObject2;
            GameView.this.runView((Canvas)localObject2);
            localObject1 = localObject2;
            if (localObject2 == null) {
              continue;
            }
            this.m_holder.unlockCanvasAndPost((Canvas)localObject2);
          }
          finally
          {
            localObject2 = localObject1;
            localObject4 = localObject1;
          }
        }
        catch (IllegalArgumentException localIllegalArgumentException)
        {
          if (localObject2 == null) {
            continue;
          }
          this.m_holder.unlockCanvasAndPost((Canvas)localObject2);
        }
        catch (NullPointerException localNullPointerException)
        {
          if (localObject4 == null) {
            continue;
          }
          this.m_holder.unlockCanvasAndPost(localObject4);
        }
        finally
        {
          if (localNullPointerException != null) {
            this.m_holder.unlockCanvasAndPost(localNullPointerException);
          }
        }
      }
    }
  }
}


/* Location:           D:\Tool\AndroidKiller_v1.3.1\projects\petdesigner\ProjectSrc\classes-dex2jar.jar
 * Qualified Name:     com.nPones.GameView
 * JD-Core Version:    0.7.0.1
 */